package zuoye;

/**
 * 1.继承
 * 2.重写
 */
class Flower{//花朵类
    String color;//花瓣颜色
    int PetalNumber;//花瓣数量
    String PetalType;//花瓣类型
    private String flowerTime;//花期
    public void setFlowerTime(String flowerTime){
        this.flowerTime = flowerTime;
    }
    public String getFlowerTime(){
        return flowerTime;
    }
    public void setColor(String color){
        this.color = color;//设置花瓣颜色
    }
    public  String getColor(){
        return color;
    }
}
// 牡丹花继承了花朵类
class Peony extends Flower{
    String flowerTime;
    public void flowerLanguage(){
        System.out.println("一朵牡丹，国色天香");
    }
    public void setFlowerTime(String flowerTime){//重写
        if(this.color.equals("黄色")){//黄色花朵是五月
            this.flowerTime ="5月";
        }else {
            this.flowerTime = flowerTime;//用户输入的花期
        }
    }
    public String getFlowerTime(){
        return flowerTime;
    }
}
public class demo1 {
    public static void main(String[] args) {
        Peony peony = new Peony();
        peony.setColor("黄色");
        peony.setFlowerTime("3月-4月");
        System.out.println("黄色牡丹花期"+peony.getFlowerTime());
        peony.PetalNumber = 1000;
        peony.PetalType = "重瓣型";
        System.out.println("牡丹花颜色"+ peony.getColor() );
        peony.flowerLanguage();
    }
}